package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoArtDoor;
import com.muyu.danmo.service.IDanmoArtDoorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 书画院校门头Controller
 *
 * @author yangle
 * @date 2024-10-31
 */
@RestController
@RequestMapping("/artDoor")
public class DanmoArtDoorController extends BaseController
{
    @Autowired
    private IDanmoArtDoorService danmoArtDoorService;

    /**
     * 查询书画院校门头列表
     */
//    @RequiresPermissions("system:artDoor:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoArtDoor>> list(DanmoArtDoor danmoArtDoor)
    {
        startPage();
        List<DanmoArtDoor> list = danmoArtDoorService.selectDanmoArtDoorList(danmoArtDoor);
        return getDataTable(list);
    }

    /**
     * 导出书画院校门头列表
     */
//    @RequiresPermissions("system:artDoor:export")
    @Log(title = "书画院校门头", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoArtDoor danmoArtDoor)
    {
        List<DanmoArtDoor> list = danmoArtDoorService.selectDanmoArtDoorList(danmoArtDoor);
        ExcelUtil<DanmoArtDoor> util = new ExcelUtil<DanmoArtDoor>(DanmoArtDoor.class);
        util.exportExcel(response, list, "书画院校门头数据");
    }

    /**
     * 获取书画院校门头详细信息
     */
//    @RequiresPermissions("system:artDoor:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoArtDoorService.selectDanmoArtDoorById(id));
    }

    /**
     * 新增书画院校门头
     */
//    @RequiresPermissions("system:artDoor:add")
    @Log(title = "书画院校门头", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoArtDoor danmoArtDoor)
    {
        return toAjax(danmoArtDoorService.insertDanmoArtDoor(danmoArtDoor));
    }

    /**
     * 修改书画院校门头
     */
//    @RequiresPermissions("system:artDoor:edit")
    @Log(title = "书画院校门头", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoArtDoor danmoArtDoor)
    {
        return toAjax(danmoArtDoorService.updateDanmoArtDoor(danmoArtDoor));
    }

    /**
     * 删除书画院校门头
     */
//    @RequiresPermissions("system:artDoor:remove")
    @Log(title = "书画院校门头", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoArtDoorService.deleteDanmoArtDoorByIds(ids));
    }
}
